cmake_minimum_required(VERSION 3.19)
project(wechatCopy LANGUAGES CXX)

# 修正1: 使用正确的模块名称（首字母大写）
find_package(Qt6 6.5 REQUIRED COMPONENTS
    Core
    Widgets
    Network
    Multimedia          # 原 "multimedia" → 修正为 "Multimedia"
    MultimediaWidgets   # 原 "multimediawidgets" → 修正为 "MultimediaWidgets"
)

qt_standard_project_setup()

# 添加FFmpeg的头文件路径
include_directories(D:/c++packages/ffmpeg-7.1.1-full_build-shared/include)

# 设置FFmpeg的库文件路径
set(ffmpeg_libs_dir D:/c++packages/ffmpeg-7.1.1-full_build-shared/lib)
link_directories(${ffmpeg_libs_dir})

# 使用GLOB获取FFmpeg的所有库文件
file(GLOB ffmpeg_dylibs ${ffmpeg_libs_dir}/*.lib)

qt_add_executable(wechatCopy
    WIN32 MACOSX_BUNDLE
    main.cpp
    widget.cpp
    widget.h
    widget.ui
    login.h login.cpp login.ui
    LabelUtils.h
    LabelUtils.cpp
    test.h test.cpp test.ui
    mainwindow.h mainwindow.cpp mainwindow.ui
    FFmpegProcessor.h FFmpegProcessor.cpp
)

target_link_libraries(wechatCopy
    PRIVATE
        Qt6::Core
        Qt6::Widgets
        Qt6::Network
        Qt6::Multimedia       # 原 "Qt::multimedia" → 修正为 "Qt6::Multimedia"
        Qt6::MultimediaWidgets  # 添加 MultimediaWidgets 模块
        ${ffmpeg_dylibs}      # 添加FFmpeg库
)

include(GNUInstallDirs)

install(TARGETS wechatCopy
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET wechatCopy
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
